const { ccclass, property } = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    public paint: cc.Graphics;
    public startX: number = 0;
    public startY: number = 0;
    public endX: number = 0;
    public endY: number = 0;
    start() {
        this.paint = this.node.getComponent(cc.Graphics);
    }


    /**
  * 火箭轨迹
  * @param startNode 开始的节点 
  * @param endNode  结束的节点
  */
    public setLine(p0x, p0y, p1x, p1y, color, width) {
        this.paint.strokeColor = color;//cc.color(234, 175, 103, 230);
        this.paint.lineWidth = width;
        this.paint.moveTo(p0x, p0y);
        this.paint.lineTo(p1x, p1y);
        //this.paint.quadraticCurveTo((p1x - p0x) / 2, p1y, p1x, p1y);
        this.paint.stroke();
    }

    update(dt) {
        this.paint.clear();
        this.setLine(this.startX, this.startY, this.endX, this.endY, cc.color(255, 147, 145, 255), 50);
        if (this.endX < 500) this.endX += 1;
        if (this.endY < 500) this.endY += 1;
    }
}
